package com.zzyl.nursing.controller;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.dto.NursingTaskCancelDto;
import com.zzyl.nursing.dto.NursingTaskDoDto;
import com.zzyl.nursing.dto.NursingTaskDto;
import com.zzyl.nursing.dto.NursingTaskUpdateDto;
import com.zzyl.nursing.service.INursingTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 护理任务Controller
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/nursing/nursingTask")
public class NursingTaskController extends BaseController
{

    @Autowired
    private INursingTaskService nursingTaskService;



    /**
     * 查询护理任务列表
     */
    @GetMapping("/list")
    public TableDataInfo list(NursingTaskDto nursingTaskListDto)
    {
        startPage();
        List<NursingTask> list = nursingTaskService.selectNursingTaskList(nursingTaskListDto);
        return getDataTable(list);
    }
    /**
     * 获取护任务详细信息
     */
    @GetMapping( "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(nursingTaskService.selectNursingTaskById(id));
    }
    /**
     * 取消护理任务
     */
    @PutMapping("/cancel")
    public AjaxResult cancel(@RequestBody NursingTaskCancelDto NursingTaskCancelDto){
        nursingTaskService.cancelNursingTask(NursingTaskCancelDto);
        return success();
    }
    /**
     * 执行护理任务
     */
    @PutMapping("/do")
    public AjaxResult doTask(@RequestBody NursingTaskDoDto nursingTaskDoDto){
        nursingTaskService.doNursingTask(nursingTaskDoDto);
        return success();
    }

    /**
     * 任务改期
     */
    @PutMapping("/updateTime")
    public AjaxResult updateNursingTask(@RequestBody NursingTaskUpdateDto nursingTaskUpdateDto){
        nursingTaskService.updateNursingTask(nursingTaskUpdateDto);
        return success();
    }


}
